/* 
 * Advanced Foundation Classes
 * Copyright (C) 2000/2004  Fabio Rotondo - Andrea Galimberti
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#include <afc/easygui/easygui.h>
#include <afc/easygui/widgets.h>

int dummy ( DynamicClass * dc, EasyGUIContext * context )
{
	printf ( "Item Selected\n" );

	return ( 0 );
}

int toggle ( DynamicClass * dc, EasyGUIContext * context, short val )
{
	printf ( "Item Toggled: %d\n", val );

	return ( 0 );
}

int main ( int argc, char * argv[] )
{
	AFC * afc = afc_new (); 
	EasyGUI * easygui = afc_easygui_new ( afc );
	EasyGUIContext * context;
	int afc_res = 0;

	if ( easygui == NULL ) 
	{
	  fprintf ( stderr, "Init of class EasyGUI failed.\n" );
	  return ( 1 );
	}

	afc_easygui_init ( easygui );
	context = afc_easygui_context_new ( easygui, NULL );

	afc_easygui_context_set_gui ( context, 
		"(window TITLE=\"EasyGUI: menu\" NAME=\"win\" MAINWIN "
        	"  (rows "
                "	(menubar "
                "		(menu NAME=pippo TEXT=Hello ICON=@cut"
                "			(button NAME=menu_btn_hello TEXT=Hello ICON=@copy)"
                "			(button TEXT=\"Select Me\" ICON=@copy action=dummy)"
                "			(button TEXT=Hello ICON=@copy)"
                "			(separator)"
                "			(button TEXT=Hello ICON=@copy)"
                "			(button TEXT=\"Hello this is a <b>text</b>\" ICON=@paste)"
                "			(separator)"
                "			(checkbutton name=check_menu text=\"Check Me!\" action=toggle checked)"
                "		)"
		"	) "
		"  )"
                ")" );

	if ( ( afc_res = afc_easygui_context_show ( context ) ) != AFC_ERR_NO_ERROR ) 
	{
		fprintf ( stderr, "res: %x\n", afc_res );
	} else 
		afc_easygui_main ( easygui );

	afc_easygui_delete ( easygui );
	afc_delete ( afc );

	return ( 0 ); 
}
